package com.aibaixun.web.controller.system;

import com.aibaixun.common.core.domain.R;
import com.aibaixun.system.domain.*;
import com.aibaixun.system.domain.dto.*;
import com.aibaixun.system.domain.vo.TpTypeListVo;
import com.aibaixun.system.service.TpLayerService;
import com.aibaixun.system.service.TpTypeService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 拓扑图层管理模块
 *
 * @author zhangyh
 * @date 2024-06-12
 **/
@RestController
@RequestMapping("/topology/layer" )
public class TpLayerController {

    @Autowired
    private TpLayerService tpLayerService;

    /**
     * 新增图层
     * @return
     */
    @ApiOperation(value = "新增图层")
    @PostMapping("/add")
    public R saveLayer(@RequestBody TpLayer dto) {
        return tpLayerService.saveLayer(dto);
    }

    /**
     * 编辑图层
     * @return
     */
    @ApiOperation(value = "编辑图层")
    @PostMapping("/update")
    public R updateLayer(@RequestBody TpLayer dto) {
        return tpLayerService.updateLayer(dto);
    }

    /**
     * 删除图层
     * @return
     */
    @ApiOperation(value = "删除图层")
    @GetMapping("/delete/{layerId}")
    public R deleteLayer(@PathVariable(value = "layerId") Long layerId) {
        return tpLayerService.deleteLayer(layerId);
    }

    /**
     * 图层分页
     * @return
     */
    @ApiOperation(value = "图层分页")
    @PostMapping("/page")
    public R<Page<TpLayer>> getLayerDataPage(@RequestBody TpLayerPageDto pageDto){
        Page page = new Page();
        page.setCurrent(pageDto.getCurrent());
        page.setSize(pageDto.getSize());
        page.setSearchCount(true);
        return tpLayerService.getLayerDataPage(page, pageDto);
    }

    /**
     * 新增图层组合
     * @return
     */
    @ApiOperation(value = "新增图层组合")
    @PostMapping("/compose/add")
    public R saveLayerCompose(@RequestBody TpLayerCompose dto) {
        return tpLayerService.saveLayerCompose(dto);
    }

    /**
     * 编辑图层组合
     * @return
     */
    @ApiOperation(value = "编辑图层组合")
    @PostMapping("/compose/update")
    public R updateLayerCompose(@RequestBody TpLayerCompose dto) {
        return tpLayerService.updateLayerCompose(dto);
    }

    /**
     * 删除图层组合
     * @return
     */
    @ApiOperation(value = "删除图层组合")
    @GetMapping("/compose/delete/{layerId}")
    public R deleteLayerCompose(@PathVariable(value = "layerId") Long layerId) {
        return tpLayerService.deleteLayerCompose(layerId);
    }

    /**
     * 获取当前可用图层信息
     * @return
     */
    @ApiOperation(value = "获取当前可用图层信息")
    @GetMapping("/compose/available")
    public R getAvailableCompose() {
        return tpLayerService.getAvailableCompose();
    }

    /**
     * 图层组合详情
     * @return
     */
    @ApiOperation(value = "图层组合详情")
    @GetMapping("/compose/detail/{composeId}")
    public R<TpLayerCompose> getLayerComposeDetail(@PathVariable(value = "composeId") Long composeId) {
        return tpLayerService.getLayerComposeDetail(composeId);
    }

    /**
     * 图层图层组合
     * @return
     */
    @ApiOperation(value = "图层图层组合")
    @PostMapping("/compose/page")
    public R<Page<TpLayerCompose>> getLayerComposeDataPage(@RequestBody TpLayerComposePageDto pageDto){
        Page page = new Page();
        page.setCurrent(pageDto.getCurrent());
        page.setSize(pageDto.getSize());
        page.setSearchCount(true);
        return tpLayerService.getLayerComposeDataPage(page, pageDto);
    }




}
